#ifndef _VEC2D_H_
#define _VEC2D_H_

#include "math.h"

namespace math
{

///////////////////////////////////////////////////////
///	\brief	Vector class that provides basic vector functionality
/// flexibility is preferred over speed.
///////////////////////////////////////////////////////
class Vec2
{
public:
			
					Vec2();
					Vec2(float _x, float _y);
	// access points for LUA Bind
	float			GetX() const { return x; };
	void			SetX(float f) { x = f; };
	float			GetY() const { return y; };
	void			SetY(float f) { y = f; };

	// functions
	int				Concurrent(const Vec2&) const;
	inline float	Magnitude() const	{		return (float)sqrt(	MagSqr()); };
	
	inline float	MagSqr() const {		return (x*x)  +	(y*y); };
	
	float			Manhatten() const;
	Vec2&			Normalize();
	void			Reset();
	void			Truncate(float MaxLength);

	void			Rotate(float Angle);

	//working with angles
	float			AngleAgainstVector(const Vec2& Vector);
	float			AngleAgainstXAxis();
	float			AngleAgainstYAxis();

	//reflecting against a normal
	void			Reflect(const Vec2& NormalVector);

	math::Vec2&		CrossProd(const math::Vec2& P, float f) {  x = P.y * f; y= P.x *-f; return *this;};
	math::Vec2&		CrossProd( float f, const math::Vec2& P) { x = P.y * -f; y= P.x *f; return *this; };
	float			DotProd(const math::Vec2& u) { return (x*u.x) + (y*u.y); };
	
	// Get address
	operator float *() { return &x;} ;

	// operators
	Vec2& operator+= ( const Vec2& _Vec) ;
	Vec2& operator-= ( const Vec2& _Vec) ;
	Vec2& operator*= ( const float& _f) ;
	Vec2& operator/= ( const float& _f) ;


    Vec2 operator + () const;
    Vec2 operator - () const;

    Vec2 operator + ( const Vec2& ) const;
    Vec2 operator - ( const Vec2& ) const;
    Vec2 operator * ( float ) const;
    Vec2 operator / ( float ) const;

    friend Vec2 operator * ( float c, const Vec2& v)
	{
		return Vec2(v.x*c, v.y*c);
	}

	friend Vec2 operator * ( const Vec2& v1, const Vec2& v2)
	{
		return Vec2(v1.x * v2.x, v1.y * v2.y);
	}



    float operator == ( const Vec2& ) const;
    float operator != ( const Vec2& ) const;


	float			x, y;
};
} // end namespace math

math::Vec2 LerpVec2(const math::Vec2& From, const math::Vec2& To, float t);

math::Vec2 GenerateNormal(const math::Vec2& FromVector);

// Operator overloads for vectors
/*math::Vec2 operator+(const math::Vec2&  vVec1, const math::Vec2&  vVec2)  ;
math::Vec2 operator-(const math::Vec2&  vVec) ;
math::Vec2 operator-(const math::Vec2&  vVec1, const math::Vec2&  vVec2) ;
math::Vec2 operator*(const math::Vec2&  vVec1, const math::Vec2& vVec2) ;	// scale each component
math::Vec2 operator/(const math::Vec2&  vVec1,float fScalar) ;
math::Vec2 operator*(const math::Vec2&  vVec1, float fScalar) ;
math::Vec2 operator*(float fScalar, const math::Vec2&  vVec1) ;
*/

float   operator^(const math::Vec2&  vVec1, const math::Vec2&  vVec2) ;   // DOT product



#endif